package com.itheima.Jiuye08;

public class Student01 implements Comparable<Student01>{
    String name;
    int age ;
    double fenshu;

    public Student01() {
    }

    public Student01(String name, int age, double fenshu) {
        this.name = name;
        this.age = age;
        this.fenshu = fenshu;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getFenshu() {
        return fenshu;
    }

    public void setFenshu(double fenshu) {
        this.fenshu = fenshu;
    }

    @Override
    public String toString() {
        return "Student01{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", fenshu=" + fenshu +
                '}';
    }
   // 成绩做降序排序，
   // 如果成绩一样，那在成绩排序的基础上按照年龄由小到大排序
    @Override
    public int compareTo(Student01 o) {
        int a = (int) (o.fenshu - this.fenshu);
        a = a == 0 ? o.age - this.age :a;
        return a;
    }
}
